package cn.tx.controller;

import java.util.List;

import cn.tx.model.Dep;
import cn.tx.query.DepQuery;
import cn.tx.service.DepService;
import cn.tx.util.Page;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ModelDriven;

public class DepAction extends BaseAction implements ModelDriven<Dep>{
	
	private Dep dep = new Dep();
	
	private DepService depService;
	
	
	
	
	public Dep getDep() {
		return dep;
	}

	public void setDep(Dep dep) {
		this.dep = dep;
	}

	/**
	 * 查询对象
	 */
	private DepQuery erpQuery = new DepQuery();
	
	
	public DepService getDepService() {
		return depService;
	}

	public void setDepService(DepService depService) {
		this.depService = depService;
	}
	

	public DepQuery getErpQuery() {
		return erpQuery;
	}

	public void setErpQuery(DepQuery erpQuery) {
		this.erpQuery = erpQuery;
	}

	/**
	 * 查询员工的列表
	 * @return
	 */
	public String dep_list(){
		//获得action的容器
		ActionContext context = ActionContext.getContext();
		Page page = depService.selectObjectByConditionPage(erpQuery, exclude);
		context.put("page", page);
		
		return SUCCESS;
	}
	
	/**
	 * 跳转到添加页面
	 * @return
	 */
	public String dep_input(){
		
		return SUCCESS;
	}
	/**
	 * 跳转到修改页面
	 * @return
	 */
	public String dep_preupdate(){
		dep = depService.getObjectById(dep.getDepId());
		return SUCCESS;
	}
	/**
	 * 保存
	 * @return
	 */
	public String dep_save(){
		depService.save(dep);
		return TOLIST;
	}
	/**
	 * 修改
	 * @return
	 */
	public String dep_update(){
		depService.update(dep);
		return TOLIST;
	}
	/**
	 * 修改
	 * @return
	 */
	public String dep_delete(){
		dep = depService.getObjectById(dep.getDepId());
		depService.delete(dep);
		return TOLIST;
	}

	@Override
	public Dep getModel() {
		return dep;
	}
	
	
	
	

}
